<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>账号登录</title>
    <!-- css import -->
    <link type="text/css" rel="stylesheet" href="${ctx}/css/login.css"/>
    <!-- js import -->
    <script type="text/javascript" src="${ctx}/js/easyui/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/jquery-md5-min.js"></script>
    <script type="text/javascript" src="${ctx}/js/pptBox.js"></script>
</head>
<script type="text/javascript">
    //解决ie不支持trim
    $(document).ready(
            function () {
                if (!String.prototype.trim) {
                    String.prototype.trim = function () {
                        return this.replace(/^\s+|\s+$/g, '');
                    };
                }
            }
    );
    //回车登录
    document.onkeydown = function mykeyDown(e) {
        //compatible IE and firefox because there is not event in firefox
        e = e || event;
        if (e.keyCode == 13) {
            sumbit();
        }
        return;
    };

    //登录操作
    function sumbit() {
        var uname = $('#userEname2').val();
        var upass = $('#upass').val();
        if (uname == null || uname == "") {
            setErrMsg('请输入用户名');
            $('#userEname2').focus();
            return;
        }
        if (upass == null || upass == "") {
            setErrMsg('请输入密码');
            $('#upass').focus();
            return;
        }
        var isCode = "<%= isRandCode%>";
        if ("T" == isCode) {
            var paCode = $("#pass_rand").val();
            if (paCode == null || paCode == "") {
                setErrMsg('请输入验证码');
                $('#pass_rand').focus();
                return;
            }
            $("#req_rand").val(paCode);
        }
        $("#userEname").val(uname);
        $("#userPass").val(upass.md5());
        //数据提交
        $.ajax({
            url: '${ctx}/passport/login/login',
            type: 'post',
            data: $("#inputForm").serialize(),
            success: function (jdata) {
                //var jdata = jQuery.parseJSON(data);
                if (jdata.flag == 'T') {
                    //使用此种方式防止外部系统登录无法跨域访问
                    var toUrl = jdata.msg;
                    if (toUrl == "") {
                        toUrl = '${param.go}';
                    }
                    window.location.href = toUrl;
                } else {
                    clearForm();
                    setErrMsg(jdata.msg);
                }
            },
            error: function (data) {
                setErrMsg('与服务器连接失败');
            }
        });
    }

    //清空表单数据
    function clearForm() {
        $("#upass").val("");
    }

    function setErrMsg(msg) {
        $("#error-mess").css('display', 'none');
        $("#error-mess").toggle();
        $("#error-message").html(msg);
    }
</script>
<body>
<div class="header"></div>
<div class="main">
    <div class="container container-custom">
        <div class="row wrap-login">
            <div class="login-banner col-sm-6 col-md-7 col-lg-7 hidden-xs" id="xxx">
                <script type="text/javascript">
                    var box = new PPTBox();
                    box.width = 559; //宽度
                    box.height = 527;//高度
                    box.autoplayer = 10;//自动播放间隔时间
                    //box.add({"url":"图片地址","title":"悬浮标题","href":"链接地址"})
                    box.add({"url": "${ctx}/images/tu1.jpg", "href": "#", "title": "悬浮提示标题1"});
                    box.add({"url": "${ctx}/images/tu2.jpg", "href": "#", "title": "悬浮提示标题2"});
                    box.add({"url": "${ctx}/images/tu3.jpg", "href": "#", "title": "悬浮提示标题3"});
                    box.add({"url": "${ctx}/images/tu4.jpg", "href": "#", "title": "悬浮提示标题4"});
                    box.show();
                </script>
            </div>
            <div class="login-user col-xs-12 col-sm-6 col-md-5 col-lg-5">
                <div class="login-part">
                    <h3>帐号登录</h3>
                    <div class="user-info">
                        <div class="user-pass">
                            <form action="" method="post" id="inputForm">
                                <input type="hidden" name="go" value="${parameter_go!''}"/>
                                <input type="hidden" name="cset" value="${parameter_cset!''}"/>
                                <input type="hidden" name="sys" value="${parameter_sys!''}"/>
                                <input type="hidden" name="_client" value="${parameter_client!''}"/>
                                <input type="hidden" name="clientid"
                                       value="${parameter_clientId!''}"/>
                                <input type="hidden" name="redirect_uri"
                                       value="${parameter_redirect_uri!''}"/>
                                <input type="hidden" name="response_type"
                                       value="${parameter_response_type!''}"/>
                                <input type="hidden" name="scope"
                                       value="${parameter_scope!''}"/>
                                <input id="userPass" name="userPass" type="hidden"/>
                                <input id="userEname" name="userEname" type="hidden"/>
                            </form>
                            <form name="inputForm" method="post" action="">
                                <div class="user-name">
                                    <input id="userEname2" name="userEname" tabindex="1"
                                           placeholder="输入用户名/邮箱" type="text" value=""/>
                                </div>
                                <div class="pass-word">
                                    <input id="upass" tabindex="2" placeholder="输入密码"
                                           type="password" autocomplete="off"/>
                                </div>
                            </form>
<#if "T"==isRandCode>
                            <div class="pass-word">
                                <input type="text" id="pass_rand" class="rand" placeholder="验证码"
                                       onclick="if(document.getElementById('verifyCode').style.visibility=='hidden'){viewVerifyCode();}"/>
                                <span class="randpic"><img id="verifyCode" src=""
                                                           onclick="viewVerifyCode();"
                                                           style="visibility:hidden;"/></span>
                            </div>
</#if>
                            <div class="error-mess" id="error-mess" style="display: none;">
                                <span class="error-icon"></span>
                                <span id="error-message"></span>
                            </div>
                            <div class="row forget-password"> <span
                                    class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                 <%-- <input type="checkbox" name="rememberMe" id="rememberMe" value="true"
                             class="auto-login" tabindex="3"/>
                 <label for="rememberMe">下次自动登录</label> 
                 --%>
                  </span> <span class="col-xs-6 col-sm-6 col-md-6 col-lg-6 forget tracking-ad"
                                data-mod="popu_26"> <a href="${ctx}/passport/reg/passport-mn.action"
                                                       tabindex="4">忘记密码?</a> </span></div>
                            <input class="logging" accesskey="l" value="登 录" tabindex="5"
                                   type="button" onclick="sumbit();"/>
                        </div>
                    </div>
                    <div class="line"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="footer">
    Copyright © 2018 - 2022 <br>
    推荐使用浏览器：IE9、360浏览器、火狐、谷歌 <br>
</div>
</body>
</html>
<script>
    //验证码刷新
    function viewVerifyCode() {
        document.getElementById("verifyCode").style.visibility = "visible";
        document.getElementById("verifyCode").src = "${ctx}/web/randCode?" + Math.random();
    }
</script>
